# Contributor: Marc Vertes <mvertes@free.fr>
# Maintainer: Mikael Jenkler <mikael@jenkler.com>
pkgname=mongodb-tools
pkgver=4.2.14
pkgrel=7
pkgdesc="The MongoDB tools provide import, export, and diagnostic capabilities."
url="https://github.com/mongodb/mongo-tools"
arch="all !s390x !riscv64" # rv64 hangs
license="Apache-2.0"
makedepends="$depends_dev go cyrus-sasl-dev openssl1.1-compat-dev libpcap-dev bash perl"
options="!check"
source="$pkgname-$pkgver.tar.gz::https://github.com/mongodb/mongo-tools/archive/r$pkgver.tar.gz
	fix-build.patch
	"
builddir="$srcdir/src/github.com/mongodb/mongo-tools"

export GO111MODULE=auto

prepare() {
	mkdir -p "${builddir%/*}"
	mv "$srcdir"/mongo-tools-r$pkgver "$builddir"
	default_prepare
}

build() {
	GOROOT=/usr/lib/go GOPATH="$srcdir" ./build.sh sasl ssl
}

package() {
	cd "$builddir/bin"
	local bindir="$pkgdir/usr/bin"
	mkdir -p "$bindir"
	cp bsondump mongostat mongofiles mongoexport mongoimport \
		mongorestore mongodump mongotop mongoreplay \
		"$bindir"
}

sha512sums="
ddddf8340788635d5be60457460830f4f8be47f7e90b61e0a498a95f46d0e1671b4e1482049d761c5d5f36c63d01277753d74f6a51446340a3dd2e2e3e0de546  mongodb-tools-4.2.14.tar.gz
74e432b354fd75209b87461e54f79a173ba0d647a2e45a48d520ee9342236b6a50ef1c634312f4804402578b8534d59ebf10973ce90cae2bbe76407102f2b404  fix-build.patch
"
